package com.torchclx;


import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {

    public static void main(String[] args) throws InterruptedException {
        ScheduledService scheduledService = new ScheduledService();
        scheduledService.schedule(()->{
            System.out.println(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss SSS"))+"这是2000毫秒的定时任务");
        }, 2000);

        System.out.println("添加一个每隔500ms的定时任务");


//        scheduledService.schedule(()->{
//            System.out.println(LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss SSS"))+"这是1000毫秒的定时任务");
//        }, 1000);


        Thread.sleep(10000);

        System.out.println("中断任务");
        PriorityBlockingQueue<Job> queue = scheduledService.trigger.getQueue();
        Job peek = queue.peek();
        peek.setInterrupted(true);
    }
}
